# TODO：0.0 代码编写
import json
import hashlib
from modules.entities.chain import Block


def hash_sha256(self, block: Block):
    """
    按照既定算法对区块进行哈希
    Create a SHA-256 hash of a block
    """
    # We must make sure that the Dictionary is Ordered, or we'll have inconsistent hashes
    block_string = json.dumps(block.__dict__, sort_keys=True).encode()

    return hashlib.sha256(block_string).hexdigest()


def hash_white(self, block: Block):
    return ""



